package com.spring.mvc.exp;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @version 1.0.0
 * @Date: 2022/7/3 14:34
 * @Author ZhuYouBin
 * @Description
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    // 处理 Exception 异常
    @ExceptionHandler(value = {Exception.class})
    @ResponseBody
    public String exceptionHandler(Throwable e) {
        return "未知异常，请联系管理员！异常信息: " + e.getMessage();
    }

}
